import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
/**
 * needLogin:是否需要登录才能访问该页面
 */
const homeRoutes = [
    {
        path: '/island',
        component: () => import(/* webpackChunkName: "home" */ './views/home/Island'),
        name: "island",
        meta: {
            title: 'island',
            icon: 'icon-shouye',
        }
    },
    {
        path: '/test',
        component: () => import(/* webpackChunkName: "home" */ './views/Test'),
        name: "test",
        meta: {
            title: 'test',
            icon: 'icon-shouye',
        }
    }
]

const routes = [
    {
        path: '/index',
        redirect: '/'
    },
    {
        path: '/discovery',
        component: () => import(/* webpackChunkName: "home" */ './views/Discovery'),
        name: "discovery",
        meta: {
            title: '发现',
            icon: 'icon-faxian',
            showTabBar: true,
        }
    },
    {
        path: '/attention',
        component: () => import(/* webpackChunkName: "home" */ './views/Attention'),
        name: "attention",
        meta: {
            title: '关注',
            icon: 'icon-guanzhu',
        }
    },
    {
        path: '/home',
        component: () => import(/* webpackChunkName: "home" */ './views/Home'),
        name: "home",
        redirect: '/home/h1',
        meta: {
            title: '我的',
            icon: 'icon-Profile',
        },
        children: [
            {
                path: 'h1',
                name: 'h1',
                component: () => import(/* webpackChunkName: "home" */ './views/home/Bottle'),
            },
            {
                path: 'h2',
                name: 'h2',
                component: () => import(/* webpackChunkName: "home" */ './views/home/Health'),
            },
            {
                path: 'h3',
                name: 'h3',
                component: () => import(/* webpackChunkName: "home" */ './views/home/Resource'),
            },
            {
                path: 'h4',
                name: 'h4',
                component: () => import(/* webpackChunkName: "home" */ './views/home/Setting'),
            }
        ]
    },
    {
        path: '/',
        component: () => import(/* webpackChunkName: "home" */ './views/Index'),
        name: "index",
        meta: {
            title: '地球',
            icon: 'icon-Gardenmaintenance1x',
        }
    },
    ...homeRoutes,
]


const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router
